
import CountUI from '../../component/Count'
import { createIncreatementAction, createDecreatementAction, createIncreatmentAsyncAction } from '../../redux/countAction'

// 引入connect连接UI组件和redux
import { connect } from 'react-redux'

// 返回一个对象，返回的对象会出现在ui组件的props中，mapStateToProps是传递的状态
function mapStateToProps( state ){
    return { count: state }
}

// 返回一个对象，返回的对象会出现在ui组件的props中，mapDispatchToProps是传递的操作状态的方法
function mapDispatchToProps( dispatch ){
    return {
        jia: value => { dispatch( createIncreatementAction( value ) ) },
        jian: value => { dispatch( createDecreatementAction( value ) ) },
        jiaAsync: ( value, time ) => { dispatch( createIncreatmentAsyncAction( value, time ) ) }
    }
}


export default connect( mapStateToProps, mapDispatchToProps )( CountUI )